/*
 * Copyright:   2015 中国平安保险（集团）股份有限公司 版权所有
 * Company:     平安科技养老险及健康险系统开发部
 * Create at:   2015-1-21
 */
package com.paic.mhis.hcpms.common.thread;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import com.paic.mhis.common.queue.biz.service.MessageSubscribe;

/**
 * Listener的方式在后台执行一线程监听发布的消息
 * 
 * @author ex-chenyonghong001
 */
@Component
public class UploadFileListener implements InitializingBean {
	private Log logger = LogFactory.getLog(this.getClass());
	@Autowired
	private MessageSubscribe redisQueueSubscribe;
	@Value("${filePublishTitle}")
	private String filePublishTitle;

	@Override
	public void afterPropertiesSet() throws Exception {
		new Thread(new Runnable() {

			@Override
			public void run() {
				logger.info("begin to subscribe channle " + filePublishTitle);
				redisQueueSubscribe.subscribeTopic("uploadFileMsgHandle", filePublishTitle);
			}

		}).start();

	}
}
